package com.example.dddsample.application.api;

import com.example.commom.model.ApiResult;
import com.example.dddsample.application.api.request.KafkaRequestDTO;
import com.example.dddsample.application.service.KafkaAppService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: bebm
 * @date: 2022/4/6 16:57
 * @description:
 */
@RestController
@Slf4j
@RequestMapping(value = "/api/v1/kafka")
public class KafKaApi {
    /**
     * kafkaAppService
     */
    private final KafkaAppService kafkaAppService;

    /**
     * KafKaApi
     * @param kafkaAppService kafkaAppService
     */
    public KafKaApi(KafkaAppService kafkaAppService){
         this.kafkaAppService=kafkaAppService;
    }

    @PostMapping("_add")
    ApiResult createTopic(@RequestBody KafkaRequestDTO kafkaRequestDTO){
        kafkaAppService.createTopic(kafkaRequestDTO);
        return ApiResult.OK_EMPTY;
    }


    @PostMapping("_delete")
    ApiResult deleteTopic(@RequestBody KafkaRequestDTO kafkaRequestDTO){
        kafkaAppService.deleteTopic(kafkaRequestDTO);
        return ApiResult.OK_EMPTY;
    }



}
